package com.zbkj.admin.boot.redisson.locker;

import com.zbkj.admin.boot.redisson.common.RedisNameResolver;
import org.redisson.api.RedissonClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 分布式锁自动化配置
 *
 * @author L.cm
 */
@Configuration
//@ConditionalOnBean(RedissonClient.class)
@EnableConfigurationProperties(MicaLockProperties.class)
public class RedissonLockConfiguration {

	@Bean
	public RedisLockClient redisLockClient(RedissonClient client,
										   RedisNameResolver resolver) {
		return new RedisLockClientImpl(client, resolver);
	}

	@Bean
	public RedisLockAspect redisLockAspect(RedisLockClient redisLockClient) {
		return new RedisLockAspect(redisLockClient);
	}


}
